package com.vince.hulk.mechanism
{
import com.vince.hulk.character.Character;
import com.vince.hulk.states.PlayState;

import org.flixel.FlxG;
import org.flixel.FlxSprite;

/**
 * 
 * author yangwz
 */		
public class Door extends FlxSprite implements IMechanism
{
	//==========================================================================
	//  Constructor
	//==========================================================================
	/**
	 * Constructs a new <code>Door</code> instance.
	 * 
	 */
	public function Door(X:Number=0, Y:Number=0)
	{
		super(X, Y, null);
		loadGraphic(doorImg1, true, true, 20, 100);
		immovable = true;
	}
	//==========================================================================
	//  Variables
	//==========================================================================
	[Embed(source = "assets/DoorImg1.png")]
	private var doorImg1:Class;
	[Embed(source = "assets/DoorImg2.png")]
	private var doorImg2:Class;
	
	private var rotation:Number;
	
	private var afterActivateDoor:Door;
	
	private var thisDoor:Door;
	
	private var activated:Boolean;
	//==========================================================================
	//  Methods
	//==========================================================================
	public function activate(character:Character):void
	{
		if (!activated)
		{
			kill();
			afterActivateDoor.revive();
		}
		else
		{
			revive();
			afterActivateDoor.kill();
		}
		activated = !activated;
	}
	
	public function setAfterActivateDoor(door:Door):void
	{
		door.loadGraphic(doorImg2, true, true, 100, 20);
		afterActivateDoor = door;
		var state:PlayState = FlxG.state as PlayState;
		state.add(afterActivateDoor);
		state.doors.add(afterActivateDoor);
		afterActivateDoor.kill();
	}
	
	public function toggle():void
	{
	}
}
}